{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# 一、读取数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2023-07-19T15:18:50.081624100Z",
     "start_time": "2023-07-19T15:18:48.726762200Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "              job_name job_area provide_salary work_year          company  \\\n0          Python开发工程师   长沙·岳麓区    9千-1.5万·13薪        2年     湖南匡安网络技术有限公司   \n1       Python / AI 开发   深圳·福田区        7千-1.4万      3-4年  深圳市金牛投资（集团）有限公司   \n2        Python初级开发工程师   长沙·芙蓉区           4-7千        1年   深圳瑛雄建筑设计工程有限公司   \n3  python开发-web系统编程工程师   长沙·宁乡市       5-9千·13薪        1年     湖南医药职业中等专业学校   \n4      Python软件工程师（讲师）   长沙·长沙县        9千-1.1万        1年     长沙京云创新科技有限公司   \n\n  degree company_type term      industry_type  \n0     本科           民营   全职         通信/电信/网络设备  \n1     大专           民营   兼职           金融/投资/证券  \n2     大专           民营   全职           建筑/建材/工程  \n3     本科           民营   全职           教育/培训/院校  \n4     本科           民营   全职  计算机服务(系统、数据服务、维修)  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>job_name</th>\n      <th>job_area</th>\n      <th>provide_salary</th>\n      <th>work_year</th>\n      <th>company</th>\n      <th>degree</th>\n      <th>company_type</th>\n      <th>term</th>\n      <th>industry_type</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>Python开发工程师</td>\n      <td>长沙·岳麓区</td>\n      <td>9千-1.5万·13薪</td>\n      <td>2年</td>\n      <td>湖南匡安网络技术有限公司</td>\n      <td>本科</td>\n      <td>民营</td>\n      <td>全职</td>\n      <td>通信/电信/网络设备</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>Python / AI 开发</td>\n      <td>深圳·福田区</td>\n      <td>7千-1.4万</td>\n      <td>3-4年</td>\n      <td>深圳市金牛投资（集团）有限公司</td>\n      <td>大专</td>\n      <td>民营</td>\n      <td>兼职</td>\n      <td>金融/投资/证券</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>Python初级开发工程师</td>\n      <td>长沙·芙蓉区</td>\n      <td>4-7千</td>\n      <td>1年</td>\n      <td>深圳瑛雄建筑设计工程有限公司</td>\n      <td>大专</td>\n      <td>民营</td>\n      <td>全职</td>\n      <td>建筑/建材/工程</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>python开发-web系统编程工程师</td>\n      <td>长沙·宁乡市</td>\n      <td>5-9千·13薪</td>\n      <td>1年</td>\n      <td>湖南医药职业中等专业学校</td>\n      <td>本科</td>\n      <td>民营</td>\n      <td>全职</td>\n      <td>教育/培训/院校</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>Python软件工程师（讲师）</td>\n      <td>长沙·长沙县</td>\n      <td>9千-1.1万</td>\n      <td>1年</td>\n      <td>长沙京云创新科技有限公司</td>\n      <td>本科</td>\n      <td>民营</td>\n      <td>全职</td>\n      <td>计算机服务(系统、数据服务、维修)</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取csv文件\n",
    "df = pd.read_csv('data.csv')\n",
    "# head()函数只读取前5条数据\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-07-19T15:20:28.040638100Z",
     "start_time": "2023-07-19T15:20:28.026647600Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 二、处理数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "data": {
      "text/plain": "['本科', '硕士', '大专']"
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": "[14, 4, 2]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "edu_type = df['degree'].value_counts().index.to_list()\n",
    "edu_num = df['degree'].value_counts().to_list()\n",
    "display(edu_type, edu_num)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-07-19T15:23:38.718350800Z",
     "start_time": "2023-07-19T15:23:38.708373800Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 三、可视化输出"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "data": {
      "text/plain": "'G:\\\\PythonLearning\\\\PythonCode\\\\python_basic_konwledge\\\\基础项目\\\\51job-data-analysis\\\\职位数据分析\\\\render.html'"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "x_data = edu_type\n",
    "y_data = edu_num\n",
    "data = [list(z) for z in zip(x_data, y_data)]\n",
    "data.sort(key=lambda x: x[1])\n",
    "pie = Pie()\n",
    "pie.add(\n",
    "    series_name=\"地区\",\n",
    "    data_pair=data,\n",
    ")\n",
    "pie.set_global_opts(\n",
    "    title_opts=opts.TitleOpts(\n",
    "        title=\"python职位学历要求\",\n",
    "        pos_left=\"left\",\n",
    "    )\n",
    ")\n",
    "pie.set_series_opts(\n",
    "    label_opts=opts.LabelOpts(),\n",
    ")\n",
    "pie.render()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-07-19T15:45:20.119183200Z",
     "start_time": "2023-07-19T15:45:20.099202700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
